package oyxUtil;

import java.util.List;

public class CollectionPageUtil<T> {
	//1、合理化 用户 要访问的 pageNo
	//2、将前端所需要的 所有 数据 封装到 PageUtil对象中 ，传递 到前端页面的时候 只需要传递一个数据好了
	private  Integer collectionPageNo;//访问页
	private Integer collectionPageSize;//每页展示数量
	private Integer collectionRows;//总条数
	private Integer collectionPageTotal;//总页数
	private  List<T> list;//前端页面 展示的数据
	
	//编写  构造函数  用来 合法化  pageNo ， pageTotal合理化 
	public CollectionPageUtil(Integer collectionPageNo, Integer collectionPageSize, Integer collectionRows) {
		//将 pageSize 和  rows直接 赋值
		this.collectionPageSize = collectionPageSize;
		this.collectionRows = collectionRows;
		//计算总页数
		this.collectionPageTotal = this.collectionRows % this.collectionPageSize == 0?
				this.collectionRows /this.collectionPageSize : (this.collectionRows /this.collectionPageSize)+1;
		//合法化 pageNo
		if(collectionPageNo == null){
			this.collectionPageNo =1;
		}else if(collectionPageNo<1){
			this.collectionPageNo =1;
		}else if (this.collectionPageTotal == 0) {
			this.collectionPageTotal =1;
			this.collectionPageNo =1;
		}else if (collectionPageNo >this.collectionPageTotal) {
			this.collectionPageNo = this.collectionPageTotal;
		}else {
			this.collectionPageNo = collectionPageNo;
		}
	}
	
	
	
	
	
	
	public Integer getcollectionPageNo() {
		return collectionPageNo;
	}
	
	public void setcollectionPageNo(Integer pageNo) {
		this.collectionPageNo = pageNo;
	}
	public Integer getCollectionPageSize() {
		return collectionPageSize;
	}
	public void setCollectionPageSize(Integer pageSize) {
		this.collectionPageSize = collectionPageSize;
	}
	public Integer getcollectionRows() {
		return collectionRows;
	}
	public void setcollectionRows(Integer rows) {
		this.collectionRows = rows;
	}
	public Integer getcollectionPageTotal() {
		return collectionPageTotal;
	}
	public void setcollectionPageTotal(Integer pageTotal) {
		this.collectionPageTotal = pageTotal;
	}
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}
	
	
	
	
	

}
